<%--
  Created by IntelliJ IDEA.
  User: 小文
  Date: 2021/8/6
  Time: 16:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>手机信息</title>
</head>
<body>
    <table border="1">
        <tr>
            <th colspan="3">手机信息</th>
        </tr>
        <tr>
            <th>品牌型号</th>
            <th>参考报价</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${list}" var="h">
            <tr>
                <td>${h.nameType}</td>
                <td>${h.price}</td>
                <td>
                    <a href="${pageContext.request.contextPath}/hand/findId?hsId=${h.hsId}">详情</a>
                    <a href="#" onclick="del(${h.hsId})">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</body>
<script src="${pageContext.request.contextPath}js/jquery-1.8.3.js"></script>
<script>
    function del(hsId) {
        if (confirm("确认要删除吗？")){
            $.post("${pageContext.request.contextPath}/hand/delete",{"hsId":hsId},function (date) {
                if (date>0){
                    alert("删除成功！")
                    location.href = 'hand/list';
                }else {
                    alert("删除失败！")
                }
            })
        }
    }
</script>
</html>
